package Demo05.Demo03;

import java.io.*;



public class Demo3_Demo {

    public static void main(String[] args) {
        BufferedInputStream br = null;
        BufferedOutputStream bm = null;
        try {

            File f=new File("G:\\a.txt");
            FileWriter fw =new FileWriter(f);;
            br  = new BufferedInputStream(new FileInputStream("G:\\a.txt"));
            bm  = new BufferedOutputStream(new FileOutputStream("G:\\acopy.txt"));
            int l = 0;
            byte[] b = new byte[1024];
            while ((l = br.read(b))!=-1){
                bm.write(b);
                bm.flush();
            }

            if(f.exists()){
                System.out.println("文件已存在。。。");
                System.out.println("复制成功");

            }else{
                f.createNewFile();
            }

            fw.close();
            br.close();
            bm.close();
        } catch (IOException e) {

            e.printStackTrace();

        }

    }

}